'''
Created on Apr 21, 2009

@author: colas
'''
import nodes
import time
import pymel as pm
def test ():
    nodeList = list()
    characterName = 'bobby01'
    nodes.registerVirtualNode()
    char = nodes.CharacterNode(characterName=characterName)
    world = nodes.WorldNode(characterName=characterName,connectTo=char.master_input)
    nodeList.append(world)
    root = nodes.RootNode(characterName=characterName,connectTo=world.master_input)
    nodeList.append(root)
    r_hips = nodes.BoneNode(characterName=characterName,connectTo=root.right_input,name='hips',side='r')
    nodeList.append(r_hips)
    r_leg = nodes.LegNode(characterName=characterName,connectTo=r_hips.master_input,side='r')
    nodeList.append(r_leg)
    r_foot = nodes.FootNode(characterName=characterName,connectTo=r_leg.master_input,side='r')
    nodeList.append(r_foot)
    l_hips = nodes.BoneNode(characterName=characterName,connectTo=root.left_input,name='hips',side='l')
    nodeList.append(l_hips)
    l_leg = nodes.LegNode(characterName=characterName,connectTo=l_hips.master_input,side='l')
    nodeList.append(l_leg)
    l_foot = nodes.FootNode(characterName=characterName,connectTo=l_leg.master_input,side='l')
    nodeList.append(l_foot)
    spine = nodes.SpineNode(characterName=characterName,connectTo=root.master_input)
    nodeList.append(spine)
    r_clavicle = nodes.ClavicleNode(characterName=characterName,connectTo=spine.right_input,side='r')
    nodeList.append(r_clavicle)
    r_arm = nodes.ArmNode(characterName=characterName,connectTo=r_clavicle.master_input,side='r')
    nodeList.append(r_arm)
    r_hand = nodes.HandNode(characterName=characterName,connectTo=r_arm.master_input,side='r',fingerNumber=4,thumb=True)
    nodeList.append(r_hand)
    l_clavicle = nodes.ClavicleNode(characterName=characterName,connectTo=spine.left_input,side='l')
    nodeList.append(l_clavicle)
    l_arm = nodes.ArmNode(characterName=characterName,connectTo=l_clavicle.master_input,side='l')
    nodeList.append(l_arm)
    l_hand = nodes.HandNode(characterName=characterName,connectTo=l_arm.master_input,side='l',fingerNumber=4,thumb=True)
    nodeList.append(l_hand)
    neck = nodes.NeckNode(characterName=characterName,connectTo=spine.master_input)
    nodeList.append(neck)
    head = nodes.HeadNode(characterName=characterName,connectTo=neck.master_input)
    nodeList.append(head)
    
    for node in nodeList :
        node.buildProxy()
        
    neck.getProxyNode().addMiddleControl()
    pm.refresh()
    neck.getProxyNode().removeMiddleControl()
    pm.refresh()
    neck.getProxyNode().addMiddleControl()
    
    r_leg.setTwoJoints(True)
    pm.refresh()
    r_leg.setTwoJoints(False)
    pm.refresh()
    r_leg.setTwoJoints(True)
    pm.refresh()
    l_leg.setTwoJoints(True)
    pm.refresh()
    l_leg.setTwoJoints(False)
    pm.refresh()
    l_leg.setTwoJoints(True)
    
    char.updateAllProxy()
    
    pm.refresh()
    
    l_leg.delete()
    char.updateAllProxy()
    pm.refresh()
    
    l_leg = nodes.LegNode(characterName=characterName,connectTo=l_hips.master_input,side='l')
    l_foot = nodes.FootNode(characterName=characterName,connectTo=l_leg.master_input,side='l')
    
    l_leg.buildProxy()
    pm.refresh()
    l_foot.buildProxy()
    pm.refresh()
    char.updateAllProxy()
    pm.refresh()
    
    world.getProxyNode().buildSkeleton()
    pm.refresh()
    root.getProxyNode().buildSkeleton()
    pm.refresh()
    l_hips.getProxyNode().buildSkeleton()
    pm.refresh()
    r_hips.getProxyNode().buildSkeleton()
    pm.refresh()
    l_leg.getProxyNode().buildSkeleton()
    pm.refresh()
    r_leg.getProxyNode().buildSkeleton()
    pm.refresh()
    l_foot.getProxyNode().buildSkeleton()
    pm.refresh()
    r_foot.getProxyNode().buildSkeleton()
    pm.refresh()
    spine.getProxyNode().buildSkeleton()
    l_clavicle.getProxyNode().buildSkeleton()
    pm.refresh()
    r_clavicle.getProxyNode().buildSkeleton()    
    pm.refresh()
    l_arm.getProxyNode().buildSkeleton()
    pm.refresh()
    r_arm.getProxyNode().buildSkeleton()
    pm.refresh()
    neck.jointNumber.set(3)
    neck.getProxyNode().buildSkeleton()
    pm.refresh()
    head.getProxyNode().buildSkeleton()
    pm.refresh()
    l_hand.getProxyNode().buildSkeleton()
    pm.refresh()
    r_hand.getProxyNode().buildSkeleton()
    
    
    
    